<!DOCTYPE html>
<html lang='en'>

<head>
    <meta charset='UTF-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title>Document</title>
    <script src='https://cdn.staticfile.org/react/16.4.0/umd/react.development.js'></script>
    <script src='https://cdn.staticfile.org/react-dom/16.4.0/umd/react-dom.development.js'></script>
    <!-- 生产环境中不建议使用 -->
    <script src='https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js'></script>
</head>

<body>
    <div id='app'>
    </div>
    <script type='text/babel'>
        class Weather extends React.Component{

            constructor(props){
                super(props)
                this.state = {isHot:true}
            }

            changeWeather(){
                // this指向会因为严格模式的原因变为undefined
                console.log(this)
            }

            render(){
                // 注意, 由于这样的写法是直接将changeWeather这个方法赋值给了h1的onclick属性, 也就是作为h1的点击事件的回调, 所以将来触发的时候this并不会指向Weather的实例对象. 所以这种写法是有问题的, 后面一小节会讲正确的写法
                return <h1 onClick={this.changeWeather}>天气</h1>
            }
        }

        ReactDOM.render(<Weather/>,document.getElementById('app'))
    </script>
</body>

</html>